package baiwa.rta.dao.mapping;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

import baiwa.rta.model.User;

public class UserMapping implements RowMapper<User> {

	public User mapRow(ResultSet rs, int line) throws SQLException {
		ResultSetExtractor<User> extractor = new ResultSetExtractor<User>() {
			public User extractData(ResultSet rs) throws SQLException, DataAccessException {
				User model = new User();
				model.setUserId(rs.getInt("USRID"));
				model.setUserName(rs.getString("USRNME"));
				model.setPassword(rs.getString("USRPSW"));
				model.setFirstName(rs.getString("FNAME"));
				model.setLastName(rs.getString("LNAME"));
				model.setEmail(rs.getString("EMAIL"));
				model.setCreateUser(rs.getString("CREBY"));
				model.setCreateDate(rs.getDate("CREDAT"));
				model.setUpdateUser(rs.getString("UPDBY"));
				model.setUpdateDate(rs.getDate("UPDAT"));
				model.setActive(rs.getString("ACTIVE"));
				return model;
			}
		};
		return extractor.extractData(rs);
	}
}